<!DOCTYPE html>
<html lang="en">

<head>
  <meta charset="UTF-8">
  <meta http-equiv="X-UA-Compatible" content="IE=edge">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>Document</title>
  <style>
    .box {
      width: 800px;
      height: 300px;
      background-color: #f00;
      position: relative;
    }

    .container {
      height: 100px;
      background-color: #0f0;
      position: absolute;


      width: 200px;
      /* 水平居中 */
      margin: 0 auto;
      left: 0;
      right: 0;
      bottom: 0;
      /* 垂直居中 */
      top: 0;
      margin: auto;
    }
  </style>
</head>


<body>
  <div class="box">
    <div class="container">

    </div>
  </div>
</body>

</html>